package com.goldgov;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.GetMapping;

import com.goldgov.kcloud.KcloudApplication;
import com.goldgov.kcloud.api.ApiDocket;
import com.goldgov.kcloud.api.ApiOverview;
import com.goldgov.kcloud.core.cache.Cache;
import com.goldgov.kcloud.core.cache.impl.RedisCacheImpl;
import com.goldgov.utils.HttpUtil;

import io.swagger.annotations.ApiOperation;
import springfox.documentation.spring.web.plugins.Docket;

@EnableScheduling
public class Application extends KcloudApplication{

	public static void main(String[] args) {
		KcloudApplication.startup(Application.class, args);
	}
	
	@Bean
	public Docket apiDocketPortal() {
		ApiOverview apiOverview = new ApiOverview("<宁夏党员教育综合服务平台接口清单>","<前台接口清单>");
		ApiDocket apiDocket = new ApiDocket("portal","/portal.*");//前台接口
		return apiDocket.build(apiOverview);
	}
	
	@Bean
	@ConditionalOnMissingBean(Cache.class)
	public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
		RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
		redisTemplate.setConnectionFactory(connectionFactory);
		return redisTemplate;
	}
	
	@Bean
	@ConditionalOnMissingBean(Cache.class)
	public Cache cache() {
		return new RedisCacheImpl();
	}
	
}
